//
//  EZAutoreleasePool.cpp
//  zhaitu
//
//  Created by ellzu on 13-8-3.
//  Copyright (c) 2013年 ellzu. All rights reserved.
//

#include "EZAutoreleasePool.h"
#include "EZAutoreleasePoolManager.h"


using namespace EZTally;

EZAutoreleasePool::EZAutoreleasePool()
{
    EZAutoreleasePoolManager *manager = EZAutoreleasePoolManager::DefaultManager();
    manager->AddCurrentThreadPool(this);
}

EZAutoreleasePool::~EZAutoreleasePool()
{
    EZAutoreleasePoolManager *manager = EZAutoreleasePoolManager::DefaultManager();
//    manager->AddCurrentThreadPool(this);
    manager->RemovePool(this);
    
    for (int i=0; i<objects.Count(); i++) {
        EZTallyObject *obj = objects.ObjectAtIndex(i);
        obj->Release();
    }
}

int EZAutoreleasePool::AddObject(EZTallyObject *object)
{
    objects.AddObject(object);
    return 0;
}